package com.example.servertest1;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

@SpringBootApplication
@RestController
public class Servertest1Application {

    public static void main(String[] args) {
        SpringApplication.run(Servertest1Application.class, args);
    }

    @RequestMapping(value="/",method = RequestMethod.GET)
    public Map<String,Object> getSession(HttpServletRequest request){
        String sessionId = request.getSession().getId();
        Object obj = request.getSession().getAttribute("userSession");
        Map<String,Object> map = new HashMap();
        map.put("sessionId",sessionId);
        map.put("user",obj);
        return map;
    }
}
